package concurrentsandbox;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class SampleFuture {

	public static Future<String> create1SecFuture() {
		Future<String> future = Executors.newCachedThreadPool().submit(
				new Callable<String>() {
					public String call() throws Exception {
						try {
							// ha, really expensive!
							Thread.sleep(1000);
						} catch (InterruptedException e) {
							Thread.currentThread().interrupt();
						}
						return "expensive result";
					}
				});
		return future;
	}

}
